using AutoMapper;
using Joy.Erp.BasicArchives.Core;

namespace Joy.Erp.BasicArchives.Receipt
{
    public class ReceivementAutoMapperProfile : Profile
    {
        public ReceivementAutoMapperProfile()
        {
            CreateMap<Receivement, ReceivementDto>().MapExtraProperties().ReverseMap();
            CreateMap<Receivement, ReceivementDocumentDto>().MapExtraProperties().ReverseMap();
            CreateMap<Receivement, ReceivementCreateDto>().MapExtraProperties().ReverseMap();
            CreateMap<Receivement, ReceivementUpdateDto>()
                .MapExtraProperties()
                .ForMember(dest => dest.Children, opt => opt.Ignore());
            CreateMap<ReceivementUpdateDto, Receivement>()
                .MapExtraProperties()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.OrderType, opt => opt.Ignore())
                .ForMember(dest => dest.Supplier, opt => opt.Ignore())
                .ForMember(dest => dest.Operator, opt => opt.Ignore())
                .MapChildren<ReceivementUpdateDto, Receivement, ReceivementLineCreateOrUpdateDto, ReceivementLine>();

            CreateMap<ReceivementLine, ReceivementLineDto>().MapExtraProperties().ReverseMap();
            CreateMap<ReceivementLine, ReceivementLineCreateOrUpdateDto>().MapExtraProperties().ReverseMap();
        }
    }
} 